<template>
  <div class="back-html">
    <!-- 装饰性背景元素 -->
    <div class="decoration-bg">
      <div class="floating-line line-1"></div>
      <div class="floating-line line-2"></div>
    </div>


    <el-row class="home-container">
      <!-- 文章部分 -->
      <el-col :lg="{span: 18, offset: 0}" :span="24">
        <!-- 轮播图展示 -->
        <div class="carousel-container" v-if="latestArticles.length > 0">
          <el-carousel height="350px" :autoplay="true" :interval="4000" indicator-position="inside">
            <el-carousel-item v-for="(article, index) in latestArticles" :key="index">
              <div class="carousel-content" :style="{ backgroundImage: `url(${article.coverImage})` }">
                <div class="carousel-overlay">
                  <h3 class="carousel-title">{{ article.title }}</h3>
                  <router-link :to="'/articles/' + article.id" class="read-more-btn">
                    阅读更多 →
                  </router-link>
                </div>
              </div>
            </el-carousel-item>
          </el-carousel>
        </div>

        <!-- 轮播图加载中状态 -->
        <div class="carousel-loading" v-else>
          <div class="loading-content">
            <el-skeleton animated>
              <template #template>
                <el-skeleton-item variant="image" style="width: 100%; height: 350px;" />
              </template>
            </el-skeleton>
          </div>
        </div>

        <!-- 最新说说 -->
        <div class="recent-talk">
          <div class="talk-header">
            <i class="icon-chat talk-icon"></i>
            <span class="talk-title">最新说说</span>
          </div>
          <div class="talk-content">
            <div class="talk-scroll" ref="talkScrollRef">
              <div
                v-for="(talk, index) in talks"
                :key="index"
                class="talk-item"
                :class="{ active: currentTalkIndex === index }"
              >
                <p>{{ talk.content }}</p>
                <span class="talk-time">{{ talk.time }}</span>
              </div>
            </div>
          </div>
        </div>

        <!-- 分类展示和切换 -->
        <div class="category-container">
          <div class="category-scroll-wrapper">
            <button class="scroll-btn scroll-left" @click="scrollLeft" :disabled="!canScrollLeft">
              <el-icon><ArrowLeft /></el-icon>
            </button>
            <div class="category-scroll" ref="categoryScrollRef">
              <div class="category-list">
                <div
                  class="category-item"
                  :class="{ active: selectedCategoryId === null }"
                  @click="selectCategory(null)"
                >
                  <i class="icon-fenlei category-icon"></i>
                  <span class="category-name">全部</span>
                  <span class="category-count">{{ totalSize }}</span>
                </div>
                <div
                  v-for="category in categories"
                  :key="category.id"
                  class="category-item"
                  :class="{ active: selectedCategoryId === category.id }"
                  @click="selectCategory(category.id)"
                >
                  <i class="icon-fenlei category-icon"></i>
                  <span class="category-name">{{ category.name }}</span>
                  <span class="category-count">{{ category.articleCount }}</span>
                </div>
              </div>
            </div>
            <button class="scroll-btn scroll-right" @click="scrollRight" :disabled="!canScrollRight">
              <el-icon><ArrowRight /></el-icon>
            </button>
          </div>
        </div>
        <div class="article-card"
             v-for="(item,index) of articleList"
             :key="item.id">
          <!-- 装饰性角标 -->
          <div class="article-decoration">
            <div class="corner-decoration"></div>
          </div>
          <div class="article-content-wrapper">
            <!-- 上层内容 -->
            <div class="article-upper">
              <!-- 左侧图片 -->
              <div class="article-cover-small">
                <router-link :to="'/articles/' + item.id">
                  <el-image fit="cover" :src="item.coverImage"></el-image>
                </router-link>
              </div>
              <!-- 右侧内容区域 -->
              <div class="article-main">
                <!-- 标题区域 -->
                <div class="article-header">
                  <span v-if="item.isWeight === 1" class="weight-tag">
                    <span style="color:#ffffff;background-color: #21ab64;border-radius: 20px;padding-left: 5px;padding-right: 5px">
                      <i class="icon-relieve-full">置顶</i>
                    </span>
                  </span>
                  <router-link :to="'/articles/' + item.id" class="title-link">
                    {{ item.title }}
                  </router-link>
                </div>
                <!-- 文章简介 -->
                <div class="article-summary">{{ item.summary }}</div>
                <!-- 文章信息 -->
                <div class="article-info-row">
                  <div class="info-item">
                    <el-icon color="#4ecdc4"><Calendar/></el-icon>
                    <span>{{ item.createTime.toString().split(" ")[0] }}</span>
                  </div>
                  <div class="info-item">
                    <el-icon color="#ff6b6b"><View/></el-icon>
                    <span v-if="item.viewCounts >= 1000 && item.viewCounts < 10000">{{
                        Math.floor(item.viewCounts / 1000)
                      }}k</span>
                    <span v-else-if="item.viewCounts >= 10000">{{ Math.floor(item.viewCounts / 10000) }}w</span>
                    <span v-else>{{ item.viewCounts }}</span>
                  </div>
                  <div class="info-item">
                    <el-icon color="#45b7d1"><Folder/></el-icon>
                    <span>{{ item.categoryName }}</span>
                  </div>
                  <div class="info-item">
                    <el-icon color="#f9ca24"><Timer/></el-icon>
                    <span>{{ item.readTime }}分钟阅读</span>
                  </div>
                </div>
              </div>
            </div>

          </div>
        </div>
        <el-pagination
            v-model:currentPage="currentPage"
            v-model:page-size="pageSize"
            :small="false"
            :disabled="false"
            :background="true"
            layout="prev, pager, next"
            :total="totalSize"
            @current-change="handleCurrentChange"
            class="custom-pagination"
        />
      </el-col>
      <el-col :lg="{span: 6, offset: 0}" :span="0" v-if="blogInfo">
        <div class="right-sidebar">
          <!-- Profile Card -->
          <ProfileCard :blogInfo="blogInfo"/>

          <!-- Recommended Articles -->
          <AnnouncementCard :blogInfo="blogInfo"/>

          <!-- Announcement Card -->
          <ArticleCard :articleList="articleList"/>

          <!-- Tag Cloud -->
          <!-- <tag-cloud /> -->
        </div>
        <!--        <div class="aside-wrap">-->

        <!--          &lt;!&ndash; 网站运行状态 &ndash;&gt;-->
        <!--          <el-card class="aside-card" style="font-size: 14px">-->
        <!--            <div>-->
        <!--              <i class="icon-zhexiantu"></i>-->
        <!--              网站资讯-->
        <!--            </div>-->
        <!--            <div >-->
        <!--              <div style="padding:4px 0 0">-->
        <!--                运行时间:<span style="margin-left: 10px">{{ time }}</span>-->
        <!--              </div>-->
        <!--              <div style="padding:4px 0 0">-->
        <!--                总访问量:<span style="margin-left: 10px">-->
        <!--                  {{ blogInfo.count.viewCounts }}-->
        <!--                </span>-->
        <!--              </div>-->
        <!--              <div style="padding:4px 0 0">-->
        <!--                当前在线人数:<span style="margin-left: 10px">{{ onlineCount }}</span>-->
        <!--              </div>-->
        <!--            </div>-->
        <!--          </el-card>-->
        <!--        </div>-->
      </el-col>
    </el-row>
  </div>
</template>

<script lang="ts" setup>
import request from "utils/request.js"
import {markRaw, nextTick, onBeforeMount, onMounted, onUnmounted, ref} from "vue";
import ProfileCard from "../../components/ProfileCard.vue";
import ArticleCard from "../../components/RecommendedArticles.vue";
import AnnouncementCard from "../../components/AnnouncementCard.vue";
import {Calendar, Folder, View, Timer, ArrowLeft, ArrowRight} from '@element-plus/icons-vue'

interface Article {
  id: number;
  title: string;
  summary: string;
  coverImage: string;
  createTime: string;
  viewCounts: number;
  isWeight: number;
  categoryId: number;
  categoryName: string;
  tags: string[];
  readTime: number;
}

interface BlogInfo {
  webSite: {
    title?: string;
  };
}

const articleList = ref<Article[]>([]);
const blogInfo = ref<BlogInfo>({
  webSite: {}
});
const time = ref('')
const onlineCount = ref(1)

// 分页数据
const currentPage = ref(1);
const pageSize = ref(10)
const totalSize = ref(0);
const searchTitle = ref('');

// 分类数据
const categories = ref([]);
const selectedCategoryId = ref(null);

// 分类滚动功能
const categoryScrollRef = ref(null);
const canScrollLeft = ref(false);
const canScrollRight = ref(false);

// 博客页面展示数据
const showName = ref('');
const summary = ref('');

// 最新文章数据（用于轮播图）
const latestArticles = ref<Article[]>([]);


// 说说数据和控制
const currentTalkIndex = ref(0);
const talkScrollRef = ref(null);
const talks = ref([
  { content: '今天写了一整天代码，终于把博客的新功能做完了 🎉', time: '2小时前' },
  { content: '分享一个超棒的CSS技巧，用渐变色做边框效果太酷了！', time: '5小时前' },
  { content: '最近在学Vue3的新特性，Composition API真的很香 ✨', time: '8小时前' },
  { content: '看完了一本关于设计模式的书，收获满满 📚', time: '1天前' },
  { content: '今晚的月亮好圆，写代码的心情都变好了 🌙', time: '2天前' },
  { content: '新的UI组件库终于上线了，界面颜值提升不少 💎', time: '3天前' }
]);


const getArticles = () => {
  request.get("/blog/getArticles", {
    params: {
      pageNum: currentPage.value,
      pageSize: pageSize.value,
      title: searchTitle.value,
      categoryId: selectedCategoryId.value
    }
  }).then((res: any) => {
    nextTick(() => {
      articleList.value = markRaw(res.data.records);
      totalSize.value = res.data.total
    })
  })
}

const getLatestArticles = () => {
  request.get("/blog/getArticles", {
    params: {
      pageNum: 1,
      pageSize: 4,
      title: '',
      categoryId: null
    }
  }).then((res: any) => {
    nextTick(() => {
      latestArticles.value = markRaw(res.data.records);
      console.log('轮播图数据已加载:', latestArticles.value.length);
    })
  }).catch((error) => {
    console.error('获取最新文章失败:', error);
  })
}

const getCategories = () => {
  request.get("/category/getCategories").then((res: any) => {
    nextTick(() => {
      categories.value = markRaw(res.data);
      // 分类数据加载完成后重新检查滚动按钮
      setTimeout(checkScrollButtons, 100);
    })
  })
}

const selectCategory = (categoryId: number | null) => {
  selectedCategoryId.value = categoryId;
  currentPage.value = 1;
  getArticles();
}

const checkScrollButtons = () => {
  if (categoryScrollRef.value) {
    const element = categoryScrollRef.value;
    canScrollLeft.value = element.scrollLeft > 5; // 添加一些容差
    canScrollRight.value = element.scrollLeft < (element.scrollWidth - element.clientWidth - 5);
  }
}

const scrollLeft = () => {
  if (categoryScrollRef.value) {
    const element = categoryScrollRef.value;
    const scrollAmount = Math.min(200, element.clientWidth * 0.8); // 动态计算滚动距离
    element.scrollBy({ left: -scrollAmount, behavior: 'smooth' });
    setTimeout(checkScrollButtons, 300);
  }
}

const scrollRight = () => {
  if (categoryScrollRef.value) {
    const element = categoryScrollRef.value;
    const scrollAmount = Math.min(200, element.clientWidth * 0.8); // 动态计算滚动距离
    element.scrollBy({ left: scrollAmount, behavior: 'smooth' });
    setTimeout(checkScrollButtons, 300);
  }
}

const runTime = () => {
  let timeold =
      new Date().getTime() -
      new Date(1672502400000).getTime();
  let msPerDay = 24 * 60 * 60 * 1000;
  let daysold = Math.floor(timeold / msPerDay);
  let str = "";
  let day = new Date();
  str += daysold + "天";
  str += day.getHours() + "时";
  str += day.getMinutes() + "分";
  str += day.getSeconds() + "秒";
  time.value = str;
}

const getBlogInfo = () => {
  request.get("/index/getBlogInfo").then((res: any) => {
    nextTick(() => {
      blogInfo.value = markRaw(res.data);
    })
  })
}

const isCoverRight = (index: any) => {
  return index % 2 === 0 ? "float:left" : "float:right";
}

const isWrapRight = (index: any) => {
  return index % 2 === 0 ? "float:right" : "float:left";
}

const handleSizeChange = (val: number) => {
  pageSize.value = val;
  getArticles();
}
const handleCurrentChange = (val: number) => {
  currentPage.value = val;
  getArticles();
}


// 说说自动滚动
const startTalkScroll = () => {
  setInterval(() => {
    currentTalkIndex.value = (currentTalkIndex.value + 1) % talks.value.length;
    updateTalkScroll();
  }, 3000); // 每3秒切换一次
}

// 更新说说滚动位置
const updateTalkScroll = () => {
  if (talkScrollRef.value) {
    talkScrollRef.value.style.setProperty('--current-index', currentTalkIndex.value);
    talkScrollRef.value.style.transform = `translateY(-${currentTalkIndex.value * 60}px)`;
  }
}

onBeforeMount(async () => {
  await getLatestArticles()
  await getArticles()
  await getBlogInfo()
  await getCategories()
})

// 实时显示时间
let timer: NodeJS.Timer | null = null
onMounted(() => {
  // 首页数据
  try {
    let websiteInfo = JSON.parse(sessionStorage.getItem("website"));
    if (websiteInfo) {
      showName.value = websiteInfo.showName;
      summary.value = websiteInfo.summary;
    }
  } catch (error) {
    console.warn('获取本地存储数据失败:', error);
  }

  // 确保轮播图数据在mounted时再次获取
  if (latestArticles.value.length === 0) {
    getLatestArticles();
  }

  runTime()
  timer = setInterval(() => {
    runTime()
  }, 1000)

  // 初始化滚动按钮状态
  nextTick(() => {
    checkScrollButtons();
    if (categoryScrollRef.value) {
      categoryScrollRef.value.addEventListener('scroll', checkScrollButtons);
    }

    // 监听窗口大小变化
    window.addEventListener('resize', checkScrollButtons);
  })

  // 启动说说滚动
  startTalkScroll();
})

onUnmounted(() => {
  // 清理定时器和事件监听器
  if (timer) {
    clearInterval(timer);
  }
  window.removeEventListener('resize', checkScrollButtons);
})
</script>

<style scoped lang="scss">
@import '@/assets/styles/variables.scss';

.back-html {
  background: var(--gradient-page);
  min-height: 100vh;
  position: relative;
  overflow: hidden;
  margin: 0 10px 10px 10px;
}

// 装饰性背景元素
.decoration-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}


.floating-line {
  position: absolute;
  background: var(--bg-decoration);
  animation: lineFloat 8s ease-in-out infinite;
}

.line-1 {
  width: 200px;
  height: 2px;
  top: 30%;
  right: 5%;
  transform: rotate(45deg);
  animation-delay: 1s;
}

.line-2 {
  width: 150px;
  height: 2px;
  bottom: 40%;
  left: 8%;
  transform: rotate(-30deg);
  animation-delay: 3s;
}

@keyframes float {
  0%, 100% {
    transform: translateY(0px) scale(1);
    opacity: 0.7;
  }
  50% {
    transform: translateY(-20px) scale(1.1);
    opacity: 0.4;
  }
}

@keyframes lineFloat {
  0%, 100% {
    transform: translateX(0px) rotate(45deg);
    opacity: 0.6;
  }
  50% {
    transform: translateX(10px) rotate(50deg);
    opacity: 0.3;
  }
}


.home-container {
  display: flex;
  width: 100%;
  padding: 0 40px;
  animation: card_fadenum 0.8s;
  min-height: calc(100vh - 80px);
  position: relative;
  z-index: 2;
  margin-top: 10px;
}

.carousel-container {
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.carousel-container :deep(.el-carousel) {
  border-radius: 20px;
}

.carousel-container :deep(.el-carousel__container) {
  border-radius: 20px;
  overflow: hidden;
}

.carousel-container :deep(.el-carousel__indicators--inside) {
  bottom: 20px;
  z-index: 10;
}

.carousel-container :deep(.el-carousel__indicator) {
  padding: 6px 4px;
}

.carousel-container :deep(.el-carousel__button) {
  width: 30px;
  height: 3px;
  border-radius: 2px;
  background-color: var(--bg-banner);
  border: none;
  transition: all 0.3s ease;
}

.carousel-container :deep(.el-carousel__indicator.is-active .el-carousel__button) {
  background-color: var(--bg-primary);
  width: 40px;
}

// 最新说说样式
.recent-talk {
  margin-bottom: 25px;
  margin-top: 25px;
  padding: 20px;
  background: var(--bg-card);
  border-radius: 20px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(227, 242, 253, 0.3);
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;

  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--gradient-cool);
    animation: talkGradient 3s ease-in-out infinite;
  }
}

@keyframes talkGradient {
  0%, 100% {
    background: var(--gradient-cool);
  }
  50% {
    background: var(--gradient-cool);
  }
}

.talk-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 15px;
}

.talk-icon {
  color: var(--primary-color);
  font-size: 18px;
  animation: talkBounce 2s ease-in-out infinite;
}

@keyframes talkBounce {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

.talk-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.talk-content {
  height: 60px;
  overflow: hidden;
  position: relative;
}

.talk-scroll {
  display: flex;
  flex-direction: column;
  transition: transform 0.5s ease-in-out;
}

.talk-item {
  min-height: 60px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 8px 0;
  opacity: 0.6;
  transform: scale(0.95);
  transition: all 0.5s ease;

  &.active {
    opacity: 1;
    transform: scale(1);
  }

  p {
    margin: 0 0 4px 0;
    font-size: 14px;
    line-height: 1.4;
    color: var(--text-primary);
  }

  .talk-time {
    font-size: 12px;
    color: var(--text-secondary);
  }
}


.carousel-content {
  height: 350px;
  background-size: cover;
  background-position: center;
  position: relative;
  background-repeat: no-repeat;
}

.carousel-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.7));
  color: white;
  padding: 40px 30px 30px;
  text-align: left;
}

.carousel-title {
  font-size: 2rem;
  margin-bottom: 15px;
  font-weight: bold;
  line-height: 1.3;
  color: white !important;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.read-more-btn {
  display: inline-block;
  padding: 12px 24px;
  background: var(--gradient-accent);
  color: white;
  text-decoration: none;
  border-radius: 25px;
  font-size: 1rem;
  font-weight: 600;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.read-more-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  background: var(--gradient-accent);
}


.category-container {
  margin-bottom: 25px;
  padding: 0;
}

.category-scroll-wrapper {
  display: flex;
  align-items: center;
  gap: 15px;
}

.scroll-btn {
  background: white;
  border: 2px solid #e3f2fd;
  border-radius: 20px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  color: #333;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);

  &:hover:not(:disabled) {
    color: #ff69b4;
    border-color: #ff69b4;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(255, 105, 180, 0.2);
  }

  &:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    background: var(--bg-secondary);
    border-color: #e0e0e0;
    color: #999;
  }

  .el-icon {
    font-size: 18px;
    font-weight: bold;
  }
}

.category-scroll {
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;

  &::-webkit-scrollbar {
    display: none;
  }
}

.category-list {
  display: flex;
  gap: 12px;
  padding: 5px;
  min-width: max-content;
}

.category-item {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 15px;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  min-width: auto;
  white-space: nowrap;

  &:hover {
    transform: translateY(-2px);

    .category-icon {
      color: #ff69b4;
    }

    .category-name {
      color: var(--primary-color);
    }
  }

  &.active {
    transform: translateY(-2px);

    .category-icon {
      color: #ff69b4;
    }

    .category-name {
      color: var(--primary-color);
      font-weight: 700;
    }

    .category-count {
      background-color: var(--accent-color);
      color: white;
    }
  }

  .category-icon {
    font-size: 16px;
    color: #666;
    margin-right: 6px;
    transition: all 0.3s ease;
  }

  .category-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    transition: all 0.3s ease;
  }

  .category-count {
    font-size: 14px;
    background-color: var(--bg-muted);
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: 12px;
    margin-left: 8px;
    font-weight: 500;
    transition: all 0.3s ease;
  }
}


.article-card {
  margin-bottom: 25px;
  padding: 25px;
  background: var(--bg-card);
  border-radius: 20px;
  transition: all 0.3s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(227, 242, 253, 0.3);
  position: relative;
  overflow: hidden;

  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--gradient-rainbow);
    transition: height 0.3s ease;
  }

}

.article-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);

  &::before {
    height: 6px;
  }
}

.article-decoration {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.corner-decoration {
  position: absolute;
  bottom: 15px;
  left: 15px;
  width: 30px;
  height: 30px;
  border-left: 3px solid rgba(255, 105, 180, 0.3);
  border-bottom: 3px solid rgba(255, 105, 180, 0.3);
  border-radius: 0 0 0 10px;
  transition: all 0.3s ease;
}

.article-card:hover .corner-decoration {
  border-color: rgba(255, 105, 180, 0.6);
  transform: scale(1.2);
}

.article-content-wrapper {
  display: flex;
  flex-direction: column;
  gap: 16px;
  font-size: 20px;
  position: relative;
  z-index: 2;
}

.article-upper {
  display: flex;
  gap: 15px;
}

.article-main {
  flex: 7;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-left: 15px;
}

.article-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.weight-tag {
  color: #ff69b4;
  width: 60px;
  display: flex;
  align-items: center;
}

.title-link {
  color: var(--text-primary);
  font-size: 1.3em;
  font-weight: 700;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  transition: color 0.3s ease;
}

.title-link:hover {
  color: var(--primary-color);
}

.article-summary {
  color: var(--text-secondary);
  font-size: 1.0em;
  line-height: 1.6;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.article-info-row {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid rgba(227, 242, 253, 0.3);
}

.info-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.85em;
  color: var(--text-secondary);

  span {
    font-weight: 500;
  }
}

.article-cover-small {
  flex: 3;
  width: 200px;
  height: 140px;
  overflow: hidden;
  border-radius: 12px;
  flex-shrink: 0;
}

.article-cover-small .el-image {
  width: 100%;
  height: 100%;
  transition: transform 0.3s;
}

.article-cover-small:hover .el-image {
  transform: scale(1.05);
}

.article-meta-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
  border-top: 1px solid #f0f0f0;
  font-size: 0.9em;
  color: #999;
}

.meta-left {
  display: flex;
  align-items: center;
  gap: 15px;
}

.meta-right {
  display: flex;
  align-items: center;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.category-link {
  color: #ff69b4;
  text-decoration: none;
  transition: color 0.3s;
  border: 1px solid beige;
  border-radius: 20px;
  background: var(--bg-secondary);
  padding: 4px 12px;
}

.category-link:hover {
  color: #ff1493;
}

.tags-wrapper,
.article-tag {
  display: none;
}

.aside-wrap {
  position: sticky;
  top: 10px;
  max-width: 300px;
}

.aside-card {
  margin-bottom: 20px;
  margin-left: 20px;
  line-height: 2;
  padding: 1.25rem 1.5rem;
}


.custom-pagination {
  margin-top: 30px;
  margin-bottom: 20px;
  display: flex;
  justify-content: center;

  :deep(.el-pagination) {
    .el-pager li {
      border-radius: 20px !important;
      margin: 0 6px !important;
      font-size: 16px !important;
      font-weight: 600 !important;
      background: white !important;
      border: 2px solid #e3f2fd !important;
      color: #666 !important;
      min-width: 40px !important;
      height: 40px !important;

      &:hover {
        border-color: #90caf9 !important;
        color: #1976d2 !important;
      }

      &.is-active {
        background: var(--bg-hover) !important;
        border-color: #1976d2 !important;
        color: #1976d2 !important;
      }
    }

    .btn-prev, .btn-next {
      border-radius: 20px !important;
      margin: 0 6px !important;
      font-size: 16px !important;
      font-weight: 600 !important;
      background: white !important;
      border: 2px solid #e3f2fd !important;
      color: #666 !important;
      min-width: 40px !important;
      height: 40px !important;

      &:hover:not(:disabled) {
        border-color: #90caf9 !important;
        color: #1976d2 !important;
      }

      &:disabled {
        opacity: 0.4 !important;
      }
    }
  }
}

.right-sidebar {
  flex: 6;
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-left: 40px;

  .el-card {
    border-radius: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }
}

@media (max-width: 768px) {
  .back-html {
    margin: 0 5px 5px 5px;
  }
}

</style>
